/*    */ package com.zimbra.cs.service.admin;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.AdminConstants;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.cs.account.AccessManager;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.account.Zimlet;
/*    */ import com.zimbra.cs.account.accesscontrol.ACLAccessManager;
/*    */ import com.zimbra.cs.account.accesscontrol.AdminRight;
/*    */ import com.zimbra.cs.account.accesscontrol.Rights.Admin;
/*    */ import com.zimbra.cs.zimlet.ZimletPresence.Presence;
/*    */ import com.zimbra.cs.zimlet.ZimletUtil;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import java.util.Iterator;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class GetAdminExtensionZimlets
/*    */   extends AdminDocumentHandler
/*    */ {
/*    */   public boolean domainAuthSufficient(Map<String, Object> context)
/*    */   {
/* 40 */     return true;
/*    */   }
/*    */   
/*    */   public Element handle(Element request, Map<String, Object> context) throws ServiceException {
/* 44 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/*    */     
/* 46 */     Element response = zsc.createElement(AdminConstants.GET_ADMIN_EXTENSION_ZIMLETS_RESPONSE);
/* 47 */     Element zimlets = response.addUniqueElement("zimlets");
/* 48 */     doExtensionZimlets(zsc, context, zimlets);
/*    */     
/* 50 */     return response;
/*    */   }
/*    */   
/*    */   private void doExtensionZimlets(ZimbraSoapContext zsc, Map<String, Object> context, Element response) throws ServiceException {
/* 54 */     Iterator<Zimlet> zimlets = Provisioning.getInstance().listAllZimlets().iterator();
/* 55 */     while (zimlets.hasNext())
/*    */     {
/* 57 */       Zimlet z = (Zimlet)zimlets.next();
/*    */       
/* 59 */       if (hasRightsToList(zsc, z, Rights.Admin.R_listZimlet, Rights.Admin.R_getZimlet))
/*    */       {
/*    */ 
/* 62 */         if (z.isExtension()) {
/* 63 */           boolean include = true;
/* 64 */           if ("com_zimbra_delegatedadmin".equals(z.getName()))
/* 65 */             include = AccessManager.getInstance() instanceof ACLAccessManager;
/* 66 */           if (include)
/* 67 */             ZimletUtil.listZimlet(response, z, -1, ZimletPresence.Presence.enabled);
/*    */         }
/*    */       }
/*    */     }
/*    */   }
/*    */   
/*    */   public void docRights(List<AdminRight> relatedRights, List<String> notes) {
/* 74 */     relatedRights.add(Rights.Admin.R_listZimlet);
/* 75 */     relatedRights.add(Rights.Admin.R_getZimlet);
/*    */     
/* 77 */     notes.add("Only zimlets on which the authed admin has effective " + Rights.Admin.R_listZimlet.getName() + " and " + Rights.Admin.R_getZimlet.getName() + " rights will appear in the response.");
/*    */     
/*    */ 
/*    */ 
/* 81 */     notes.add("e.g. there are zimlet1, zimlet2, zimlet3, if an admin has effective " + Rights.Admin.R_listZimlet.getName() + " and " + Rights.Admin.R_getZimlet.getName() + " rights on zimlet1, zimlet2, " + "then only zimlet1, zimlet2 will appear in the GetAdminExtensionZimletsResponse.  " + "The GetAdminExtensionZimletsRequest itself will not get PERM_DENIED.");
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/admin/GetAdminExtensionZimlets.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */